package com.xyzq.model.ya.data;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.appfuse.model.BaseObject;

@Entity
@Table(name = "account")
public class Account extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3775203519698194366L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@Column(unique = true, nullable = false)
	private Integer account;
	private String name;
	private String bank;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "Fk_STAFF_STAFF", nullable = false)
	private Staff staff;
	@Temporal(TemporalType.DATE)
	@Column(name = "open_day")
	private Date openDay;
	private String transfer;
	private String remark;
	@Column(name = "stock_sh_number")
	private String stockShNumber;
	@Temporal(TemporalType.DATE)
	@Column(name = "stock_sh_openday")
	private Date stockShOpenDay;
	@Column(name = "stock_sh_number_b")
	private String stockShNumberB;
	@Temporal(TemporalType.DATE)
	@Column(name = "stock_sh_openday_b")
	private Date stockShOpenDayB;
	@Column(name = "stock_sz_number")
	private String stockSzNumber;
	@Temporal(TemporalType.DATE)
	@Column(name = "stock_sz_openday")
	private Date stockSzOpenDay;
	@Column(name = "stock_sz_number_b")
	private String stockSzNumberB;
	@Temporal(TemporalType.DATE)
	@Column(name = "stock_sz_openday_b")
	private Date stockSzOpenDayB;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sub_time")
	private Date subTime;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "last_modify_time")
	private Date lastModifyTime;
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountDayMoney> dayMoneys;
	@OneToMany(mappedBy = "account",  cascade = CascadeType.ALL)
	private Set<AccountDayFund> dayFunds;
	@OneToMany(mappedBy = "account",  cascade = CascadeType.ALL)
	private Set<AccountDayStock> dayStocks;
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountMonthProfit> monthProfits;
	@OneToMany(mappedBy = "account",  cascade = CascadeType.ALL)
	private Set<AccountMonthReward> monthRewards;
	@OneToMany(mappedBy = "account",  cascade = CascadeType.ALL)
	private Set<AccountSpecial> specials;
	@OneToMany(mappedBy = "account",  cascade = CascadeType.ALL)
	private Set<AccountMonthAssert> monthAsserts;
	@OneToMany(mappedBy = "account",  cascade = CascadeType.ALL)
	private Set<SubAccount> subAccounts;

	public void setStaffId(Integer staffId) {
		if (staff == null) {
			staff = new Staff();
		}
		this.staff.setStaffId(staffId);
	}

	public Long getId() {
		return id;
	}

	public Integer getAccount() {
		return account;
	}

	public String getName() {
		return name;
	}

	public String getBank() {
		return bank;
	}

	public Staff getStaff() {
		return staff;
	}

	public Date getOpenDay() {
		return openDay;
	}

	public String getTransfer() {
		return transfer;
	}

	public String getRemark() {
		return remark;
	}

	public String getStockShNumber() {
		return stockShNumber;
	}

	public Date getStockShOpenDay() {
		return stockShOpenDay;
	}

	public String getStockSzNumber() {
		return stockSzNumber;
	}

	public Date getStockSzOpenDay() {
		return stockSzOpenDay;
	}

	public Date getSubTime() {
		return subTime;
	}

	public Date getLastModifyTime() {
		return lastModifyTime;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setAccount(Integer account) {
		this.account = account;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setBank(String bank) {
		this.bank = bank;
	}

	public void setStaff(Staff staff) {
		this.staff = staff;
	}

	public void setOpenDay(Date openDay) {
		this.openDay = openDay;
	}

	public void setTransfer(String transfer) {
		this.transfer = transfer;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setStockShNumber(String stockShNumber) {
		this.stockShNumber = stockShNumber;
	}

	public void setStockShOpenDay(Date stockShOpenDay) {
		this.stockShOpenDay = stockShOpenDay;
	}

	public void setStockSzNumber(String stockSzNumber) {
		this.stockSzNumber = stockSzNumber;
	}

	public void setStockSzOpenDay(Date stockSzOpenDay) {
		this.stockSzOpenDay = stockSzOpenDay;
	}

	public void setSubTime(Date subTime) {
		this.subTime = subTime;
	}

	public void setLastModifyTime(Date lastModifyTime) {
		this.lastModifyTime = lastModifyTime;
	}

	public Set<AccountDayMoney> getDayMoneys() {
		return dayMoneys;
	}

	public Set<AccountDayFund> getDayFunds() {
		return dayFunds;
	}

	public Set<AccountDayStock> getDayStocks() {
		return dayStocks;
	}

	public Set<AccountMonthProfit> getMonthProfits() {
		return monthProfits;
	}

	public Set<AccountMonthReward> getMonthRewards() {
		return monthRewards;
	}

	public Set<AccountSpecial> getSpecials() {
		return specials;
	}

	public Set<AccountMonthAssert> getMonthAsserts() {
		return monthAsserts;
	}

	public void setDayMoneys(Set<AccountDayMoney> dayMoneys) {
		this.dayMoneys = dayMoneys;
	}

	public void setDayFunds(Set<AccountDayFund> dayFunds) {
		this.dayFunds = dayFunds;
	}

	public void setDayStocks(Set<AccountDayStock> dayStocks) {
		this.dayStocks = dayStocks;
	}

	public void setMonthProfits(Set<AccountMonthProfit> monthProfits) {
		this.monthProfits = monthProfits;
	}

	public void setMonthRewards(Set<AccountMonthReward> monthRewards) {
		this.monthRewards = monthRewards;
	}

	public void setSpecials(Set<AccountSpecial> specials) {
		this.specials = specials;
	}

	public void setMonthAsserts(Set<AccountMonthAssert> monthAsserts) {
		this.monthAsserts = monthAsserts;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((account == null) ? 0 : account.hashCode());
		result = prime * result + ((bank == null) ? 0 : bank.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((lastModifyTime == null) ? 0 : lastModifyTime.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((openDay == null) ? 0 : openDay.hashCode());
		result = prime * result + ((remark == null) ? 0 : remark.hashCode());
		result = prime * result + ((staff == null) ? 0 : staff.hashCode());
		result = prime * result
				+ ((stockShNumber == null) ? 0 : stockShNumber.hashCode());
		result = prime * result
				+ ((stockShNumberB == null) ? 0 : stockShNumberB.hashCode());
		result = prime * result
				+ ((stockShOpenDay == null) ? 0 : stockShOpenDay.hashCode());
		result = prime * result
				+ ((stockShOpenDayB == null) ? 0 : stockShOpenDayB.hashCode());
		result = prime * result
				+ ((stockSzNumber == null) ? 0 : stockSzNumber.hashCode());
		result = prime * result
				+ ((stockSzNumberB == null) ? 0 : stockSzNumberB.hashCode());
		result = prime * result
				+ ((stockSzOpenDay == null) ? 0 : stockSzOpenDay.hashCode());
		result = prime * result
				+ ((stockSzOpenDayB == null) ? 0 : stockSzOpenDayB.hashCode());
		result = prime * result + ((subTime == null) ? 0 : subTime.hashCode());
		result = prime * result
				+ ((transfer == null) ? 0 : transfer.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Account other = (Account) obj;
		if (account == null) {
			if (other.account != null)
				return false;
		} else if (!account.equals(other.account))
			return false;
		if (bank == null) {
			if (other.bank != null)
				return false;
		} else if (!bank.equals(other.bank))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (lastModifyTime == null) {
			if (other.lastModifyTime != null)
				return false;
		} else if (!lastModifyTime.equals(other.lastModifyTime))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (openDay == null) {
			if (other.openDay != null)
				return false;
		} else if (!openDay.equals(other.openDay))
			return false;
		if (remark == null) {
			if (other.remark != null)
				return false;
		} else if (!remark.equals(other.remark))
			return false;
		if (staff == null) {
			if (other.staff != null)
				return false;
		} else if (!staff.equals(other.staff))
			return false;
		if (stockShNumber == null) {
			if (other.stockShNumber != null)
				return false;
		} else if (!stockShNumber.equals(other.stockShNumber))
			return false;
		if (stockShNumberB == null) {
			if (other.stockShNumberB != null)
				return false;
		} else if (!stockShNumberB.equals(other.stockShNumberB))
			return false;
		if (stockShOpenDay == null) {
			if (other.stockShOpenDay != null)
				return false;
		} else if (!stockShOpenDay.equals(other.stockShOpenDay))
			return false;
		if (stockShOpenDayB == null) {
			if (other.stockShOpenDayB != null)
				return false;
		} else if (!stockShOpenDayB.equals(other.stockShOpenDayB))
			return false;
		if (stockSzNumber == null) {
			if (other.stockSzNumber != null)
				return false;
		} else if (!stockSzNumber.equals(other.stockSzNumber))
			return false;
		if (stockSzNumberB == null) {
			if (other.stockSzNumberB != null)
				return false;
		} else if (!stockSzNumberB.equals(other.stockSzNumberB))
			return false;
		if (stockSzOpenDay == null) {
			if (other.stockSzOpenDay != null)
				return false;
		} else if (!stockSzOpenDay.equals(other.stockSzOpenDay))
			return false;
		if (stockSzOpenDayB == null) {
			if (other.stockSzOpenDayB != null)
				return false;
		} else if (!stockSzOpenDayB.equals(other.stockSzOpenDayB))
			return false;
		if (subTime == null) {
			if (other.subTime != null)
				return false;
		} else if (!subTime.equals(other.subTime))
			return false;
		if (transfer == null) {
			if (other.transfer != null)
				return false;
		} else if (!transfer.equals(other.transfer))
			return false;
		return true;
	}

	@Override
	public String toString() {
		ToStringBuilder builder = new ToStringBuilder(this);
		builder.append("id", id);
		builder.append("account", account);
		builder.append("name", name);
		builder.append("bank", bank);
		builder.append("staff", staff);
		builder.append("openDay", openDay);
		builder.append("transfer", transfer);
		builder.append("remark", remark);
		builder.append("stockShNumber", stockShNumber);
		builder.append("stockShOpenDay", stockShOpenDay);
		builder.append("stockShNumberB", stockShNumberB);
		builder.append("stockShOpenDayB", stockShOpenDayB);
		builder.append("stockSzNumber", stockSzNumber);
		builder.append("stockSzOpenDay", stockSzOpenDay);
		builder.append("stockSzNumberB", stockSzNumberB);
		builder.append("stockSzOpenDayB", stockSzOpenDayB);
		builder.append("subTime", subTime);
		builder.append("lastModifyTime", lastModifyTime);
		return builder.toString();
	}

	public void setStockShNumberB(String stockShNumberB) {
		this.stockShNumberB = stockShNumberB;
	}

	public String getStockShNumberB() {
		return stockShNumberB;
	}

	public void setStockShOpenDayB(Date stockShOpenDayB) {
		this.stockShOpenDayB = stockShOpenDayB;
	}

	public Date getStockShOpenDayB() {
		return stockShOpenDayB;
	}

	public void setStockSzNumberB(String stockSzNumberB) {
		this.stockSzNumberB = stockSzNumberB;
	}

	public String getStockSzNumberB() {
		return stockSzNumberB;
	}

	public void setStockSzOpenDayB(Date stockSzOpenDayB) {
		this.stockSzOpenDayB = stockSzOpenDayB;
	}

	public Date getStockSzOpenDayB() {
		return stockSzOpenDayB;
	}

	public void setSubAccounts(Set<SubAccount> subAccounts) {
		this.subAccounts = subAccounts;
	}

	public Set<SubAccount> getSubAccounts() {
		return subAccounts;
	}

}
